<?php

namespace Tbf\Bundle\DatabaseBundle\ListQuery\ConditionalExpress;

use Doctrine\ORM\QueryBuilder;

class InSimpleConditionalExpress extends AbstractConditionalExpress
{
    protected $field;
    protected $value;
    /**
     * @return mixed
     */
    public function getField()
    {
        return $this->field;
    }

    /**
     * @return mixed
     */
    public function getValue()
    {
        return $this->value;
    }

    public function setField($field)
    {
        $this->field = $field;
    }
    public function setValue(array $value)
    {
        $this->value = $value;
    }
    public function filterOrmQueryBuilder(QueryBuilder $qb)
    {
        $field = $this->handleFieldName($qb,$this->getField());
        $string_array = array();
        foreach ($this->getValue() as $value) {
            $string_array[] = $this->placeHolderValue($qb,$value);
        }
        $in_string = implode(',',$string_array);
        $qb->andWhere($qb->expr()->in($field,$in_string));
    }
}
